from primes import erastothenes, prime

limit = 1000000

maxlength = 0
primes = erastothenes(limit/21) # need more than 21 terms
checker = set(erastothenes(limit))

for i in xrange(0, len(primes)):
    sum = primes[i]
    length = 1
    for j in primes[i+1:]:
        sum += j
        length += 1
        if sum > limit: break
        if sum in checker and length > maxlength:
            maxlength = length
            maxsum = sum

print maxsum, maxlength
    
